package com.gxa.service.investment.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.entity.investment.ProjectTrace;
import com.gxa.entity.investment.RiskTrace;
import com.gxa.mapper.investment.RiskTraceMapper;
import com.gxa.service.investment.RiskTraceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 风险跟踪单 服务实现类
 * </p>
 *
 * @author yjl
 * @since 2022-10-17 03:04:36
 */
@Service
public class RiskTraceServiceImpl extends ServiceImpl<RiskTraceMapper, RiskTrace> implements RiskTraceService {

    @Autowired
    private RiskTraceMapper riskTraceMapper;

    @Override
    public PageInfo queryAll(Integer pageNum, Integer pageSize) {
        Page<RiskTrace> page1 = PageHelper.startPage(pageNum,pageSize);
        List<RiskTrace> projectTraceList = this.riskTraceMapper.selectList(null);
        PageInfo<RiskTrace> pageInfo = new PageInfo<RiskTrace>(projectTraceList);
        return pageInfo;
    }

    @Override
    public PageInfo queryById(Integer id,Integer pageNum, Integer pageSize) {
        LambdaQueryWrapper<RiskTrace> lqw = new LambdaQueryWrapper();
        lqw.eq(RiskTrace::getProjectId,id);
        Page<RiskTrace> page1 = PageHelper.startPage(pageNum,pageSize);
        List<RiskTrace> list = this.riskTraceMapper.selectList(lqw);
        PageInfo<RiskTrace> pageInfo = new PageInfo<RiskTrace>(list);
        return pageInfo;


    }

    @Override
    public void add(RiskTrace riskTrace) {
       riskTraceMapper.insert(riskTrace);
    }

}
